package com.stat;

import java.util.ArrayList;

import com.info.BonusInfo;
import com.info.BonusTypeEnum;
import com.info.EquipmentSlotEnum;
import com.info.ItemInfo;
import com.info.MagicItemInfo;

public class CharacterEquipment {

	private ItemInfo[] equipSlots;
	
	private CharacterEquipment(){
		this.equipSlots = new ItemInfo[EquipmentSlotEnum.values().length];
	}
	
	public void addEquipment(ItemInfo item){
		if (item.getItemSlot() == null){
			return;
		}
		this.equipSlots[item.getItemSlot().ordinal()] = item;
	}
	
	public ItemInfo getEquipment(EquipmentSlotEnum slot){
		return this.equipSlots[slot.ordinal()];
	}
	
	public void removeEquipment(EquipmentSlotEnum slot){
		this.equipSlots[slot.ordinal()] = null;
	}
	
	public boolean isSlotEmpty(EquipmentSlotEnum slot){
		return this.equipSlots[slot.ordinal()] == null;
	}
	
	public ItemInfo[] getAllEquipment(){
		return this.equipSlots;
	}
	
	public ArrayList<MagicItemInfo> getMagicEquipmentList(){
		ArrayList<MagicItemInfo> items = new ArrayList<MagicItemInfo>();
		for (ItemInfo i : equipSlots){
			if (i instanceof MagicItemInfo){
				items.add((MagicItemInfo)i);
			}
		}
		return items;
	}
	
	public BonusInfo getTotalBonus(BonusTypeEnum type, String condition){
		BonusInfo bonus = new BonusInfo();
		
		for (ItemInfo i : equipSlots){
			bonus.addBonus(i.getBonus(type, condition));
		}
		return bonus;
	}
}
